/***************************************************************************
 *   Copyright (C) 2009 by Marian Skvarek   *
 *   skvarek.marian@gmail.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A TrackICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#ifndef CEASYSCOREMAINWINDOW_H
#define CEASYSCOREMAINWINDOW_H

#include "CEasyScoreApp.h"

#include <QMainWindow>

class QAction;
class QMenu;
class QFrame;
class QKeyEvent;
class QCloseEvent;
class QActionGroup;

namespace easyscore
{
        class CEasyScoreApp;

	namespace core
	{
		class CScore;
	}
	
	namespace gui
	{
		class CGraphicsView;
	}
	
	class CEasyScoreMainWindow: public QMainWindow
	{
			Q_OBJECT
//Members
		private:
			CEasyScoreApp *mApp;
			easyscore::gui::CGraphicsView *mScoreSceneView;
			QMenu *mFileMenu;
                        QMenu *mExportMenu;
                        QMenu *mEditMenu;
                        QMenu *mHelpMenu;
                        QToolBar *mFileToolBar;
                        QToolBar *mEditToolbar;
                        QToolBar *mNoteToolBar;
                        QAction *mNewAction;
                        QAction *mOpenAction;
                        QAction *mSaveAction;
                        QAction *mSaveAsAction;
                        QAction *mExportToPDFAction;
                        QAction *mExportToTabAction;
                        QAction *mExportToMusicXML;
                        QAction *mExportToPNGAction;
                        QAction *mPrintAction;
                        QAction *mExitAction;
                        QAction *mAboutAction;
                        QAction *mInsertBarAction;
                        QActionGroup *mNoteActionGroup;
                        QAction *mNote128Action;
                        QAction *mNote64Action;
                        QAction *mNote32Action;
                        QAction *mNote16Action;
                        QAction *mNote8Action;
                        QAction *mNote4Action;
                        QAction *mNote2Action;
                        QAction *mZoomInAction;
                        QAction *mZoomOutAction;

			
//Accessors
		public:
			
//Constructors, Initialization & Destructors
		public:
			CEasyScoreMainWindow(CEasyScoreApp *app);
			void initialize();

			~CEasyScoreMainWindow();

//Overrides
		protected:
			void closeEvent ( QCloseEvent *event );
			void keyReleaseEvent ( QKeyEvent * );
			
//Public methods
                public:
                        easyscore::gui::CGraphicsView *getScoreSceneView() { return mScoreSceneView; }
			
//Protected methods
		protected:
                        //easyscore::core::CScore *getScore() { return mApp->getScore(); }

//Private Methods
		private slots:
			void newFile();
			void open();
			bool save();
			bool saveAs();
                        void exportToPDF();
                        void exportToTab();
                        void exportToMusicXML();
                        void exportToPNG();
                        void print();
			void about();
			void documentWasModified();
                        void addBar();
                        void setCurrentNote(QAction *action);
                        void zoomIn();
                        void zoomOut();


		private:
			void createActions();
			void createMenus();
			void createToolBars();
			void createStatusBar();
			void readSettings();
			void writeSettings();
			void loadFile ( const QString &fileName );
                        bool maybeSave();
			bool saveFile ( const QString &fileName );
			void setCurrentFile ( const QString &fileName );
			QString strippedName ( const QString &fullFileName );
	};

} //namespace easyscore

#endif
